package com.smart.seckilldemo.rocketmq.producer;

import com.smart.seckilldemo.commons.dto.GenerateSeckillOrder;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;


import javax.annotation.Resource;

/**
 * 下单消息队列 发送下单请求
 */
@Component
@Slf4j
public class RocketMQProducer  {

    private final static String topic = "tp_topic_1";
    @Resource
    RocketMQTemplate rocketMQTemplate;

    /**
     * 发送消息测试
     * @param msg
     */
    public void onMessage(GenerateSeckillOrder msg) {
        log.info("发送订单下单请求消息");
        rocketMQTemplate.convertAndSend(topic,msg);
    }
}
